<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增住宿生信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-stumanage-add">
            <div class="form-group">
                <label class="col-sm-2 control-label">宿舍编号：</label>
                <div class="col-sm-4">
                    <input name="dormitoryNum" class="form-control" type="text" readonly="true" th:value="${dormitoryNum}">
                </div>
                <label class="col-sm-2 control-label">学生姓名：</label>
                <div class="col-sm-4">
                    <input name="stuName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">学生年级：</label>
                <div class="col-sm-4">
                    <select name="stuGrade" class="form-control m-b" th:with="type=${@dict.getType('sys_grade_num')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
                <label class="col-sm-2 control-label">学生班级：</label>
                <div class="col-sm-4">
                    <input name="stuClass" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">学生床号：</label>
                <div class="col-sm-4">
                    <input name="stuBedno" class="form-control" type="text" required>
                </div>
                <label class="col-sm-2 control-label">联系电话：</label>
                <div class="col-sm-4">
                    <input name="stuTell" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">学生状态：</label>
                <div class="col-sm-4">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_dormitory_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
                <label class="col-sm-2 control-label">家庭住址：</label>
                <div class="col-sm-4">
                    <input name="stuAddress" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">入住时间：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="inDate" class="form-control" placeholder="请选择入住时间" readonly type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
                <label class="col-sm-2 control-label">退宿时间：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="outDate" class="form-control" placeholder="请选择退宿时间" readonly type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-10">
                    <input name="remark" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">学生照片：</label>
                <div class="col-sm-10">
                    <input type="hidden" name="stuAvatar">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="stuAvatar" name="file" type="file">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "nczxsushe/dormitory/student"
        $("#form-stumanage-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-stumanage-add').serialize());
            }
        }

        $("input[name='inDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='outDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>